Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement DFW settings Exclusion list #1037

Merged
merged 1 commit into from
Jan 7, 2024

Conversation

ksamoray
Copy link
Collaborator

Fixes: #757

@ksamoray ksamoray marked this pull request as draft November 22, 2023 13:34
@ksamoray
Copy link
Collaborator Author

/test-all

@ksamoray ksamoray marked this pull request as ready for review November 27, 2023 18:11
@ksamoray
Copy link
Collaborator Author

/test-all

8 similar comments
@ksamoray
Copy link
Collaborator Author

/test-all

@ksamoray
Copy link
Collaborator Author

/test-all

@ksamoray
Copy link
Collaborator Author

/test-all

@ksamoray
Copy link
Collaborator Author

/test-all

@ksamoray
Copy link
Collaborator Author

/test-all

@ksamoray
Copy link
Collaborator Author

/test-all

@ksamoray
Copy link
Collaborator Author

/test-all

@ksamoray
Copy link
Collaborator Author

/test-all

State: schema.ImportStatePassthrough,
},
Schema: map[string]*schema.Schema{
"member": {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make more sense to implement the list as one resource (with list of paths inside?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've considered - But then we'll run into the usual issue where this singleton NSX object is virtually indestructible using NSX API - TF doesn't really like these, I think. Is there any decent way to work around this?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can revert to default (empty list in this case?) when resource is destroyed - we do the same for vm tags, for example.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can - the question is if there is any advantage in handling this as a scalar, vs handling as a list which is more "natural" to terraform with full CRUD operation.
We've done this for context profile custom attributes and such.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My personal feeling is that a single string does not justify a dedicated resource. But I don't insist.
As long as we're sure order is not important in this list, we can do it as suggested here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@annakhm there is a more serious problem which I should look into:
When two members are created at the same time, there is a concurrency problem - both retrieve the member list, append the new member and when submitting one change is overwritten.
I'm not sure if we have some mean to handle this (and we might have this elsewhere maybe).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I worked around the concurrency problem, and added a few test. I'd rather if you could have another look...

@ksamoray
Copy link
Collaborator Author

ksamoray commented Dec 3, 2023

/test-all

@ksamoray ksamoray force-pushed the dfw_exclude_list branch 2 times, most recently from bd98c8a to 0967f5d Compare December 19, 2023 15:56
@ksamoray
Copy link
Collaborator Author

/test-all

@ksamoray
Copy link
Collaborator Author

/test-all

@ksamoray
Copy link
Collaborator Author

/test-all

@ksamoray ksamoray force-pushed the dfw_exclude_list branch 3 times, most recently from 0d8fe8f to c2d2e9b Compare December 20, 2023 11:28
@ksamoray ksamoray requested a review from annakhm December 20, 2023 11:29
@ksamoray
Copy link
Collaborator Author

/test-all

@ksamoray
Copy link
Collaborator Author

/test-all


client := security.NewExcludeListClient(getSessionContext(d, m), connector)
obj, err := client.Get()
if isNotFoundError(err) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should silently swallow the error in not found case

@annakhm
Copy link
Collaborator

annakhm commented Jan 3, 2024

I still feel like a singleton resource is better design, as it would save roundtrips and avoid concurrency problems. But I don't insist.

@ksamoray ksamoray force-pushed the dfw_exclude_list branch 2 times, most recently from 87b7bd3 to bb191cf Compare January 3, 2024 14:21
@ksamoray
Copy link
Collaborator Author

ksamoray commented Jan 3, 2024

/test-all

@ksamoray
Copy link
Collaborator Author

ksamoray commented Jan 3, 2024

I still feel like a singleton resource is better design, as it would save roundtrips and avoid concurrency problems. But I don't insist.

IMO a singleton doesn't make sense in the API level as well, from the functional aspect, e.g:

  • Why should this resource be managed from a single point?
  • Should a user be able to create dependency between a exclude list member and other resources?
  • Why would we confine an organization to maintain the exclude list from a single interface (UI, TF...)? As otherwise concurrency issues become worse.

@ksamoray
Copy link
Collaborator Author

ksamoray commented Jan 3, 2024

/test-all

@salv-orlando
Copy link
Member

@ksamoray shouldn't this PR also have doc changes since we are adding a new resource?

Regarding the singleton vs non-singleton use case, I think both @annakhm and @ksamoray have good points.
I'd tend to slightly prefer user experience over scalability, especially considering we should not see hundreds or thousands of groups in the exclusion list, so I'd say maybe concurrency is not a big concern.

@ksamoray
Copy link
Collaborator Author

ksamoray commented Jan 3, 2024

@salv-orlando yeah we need documentation but no point in adding that before we concluded the implementation.

@ksamoray
Copy link
Collaborator Author

ksamoray commented Jan 7, 2024

/test-all

@ksamoray ksamoray merged commit 886c9fe into vmware:master Jan 7, 2024
6 checks passed
@ksamoray ksamoray deleted the dfw_exclude_list branch January 7, 2024 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add resource to manage the Distributed Firewall settings "Exclusion list"
3 participants